<?php

namespace app\admin\model\shopro;

use think\Model;

class Information extends Model
{

    // 表名
    protected $name = 'shopro_information';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'status_text',
        'updatetime_text'
    ];

    public function getStatusList()
    {
        return ['1' => __('Normal'), '0' => __('Hidden')];
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }
     public function getUpdatetimeTextAttr($value, $data)
    {
       return date("Y-m-d H:i:s",$data['updatetime']);
    }
     /**
     * 获取动态明细
     *
     * @return array
     */
    public static function getList($params)
    {
        $logs = self::where('status', 1)->order('id', 'desc')->paginate($per_page ?? 10)->toArray();
        return $logs;
    }
}
